<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script type="text/javascript">
	function goPage(pageNo){
		//1:获取表单对象
		var form = document.forms[0];
		form.currentPage.value = pageNo;
		form.submit();
	}
</script>

</head>
<body>
<h1>商品列表</h1>
<a href="/product/input">添加</a>
<form action="/product/list" method="post">
<table border="1" cellpadding="0" cellspacing="0" width="60%">
	<tr>
		<td colspan="8">
			关键字:<input type="text" name="keyword" value="${qo.keyword}">
			产品名称:<select name="brandId">
				<option value="">全部</option>
				<c:forEach items="${brands}" var="brand">
					<option value="${brand.id}"
							${brand.id == qo.brandId ? 'selected' : ''}>${brand.name}</option>
				</c:forEach>
			</select>
			<input type="submit" value="查询"/>
		</td>
	</tr>
	<tr>
		<td>编号</td>
		<td>姓名</td>
		<td>商品价格</td>
		<td>品牌名称</td>
		<td>操作</td>
	</tr>
	<c:forEach items="${pageResult.data}" var="product" varStatus="vs">
		<tr>
			<td>${vs.count}</td>
			<td>${product.name}</td>
			<td>${product.price}</td>
			<td>${product.br.name}</td>
				<%--我的实体类里的定义的brand对象
			的dept可以直接传递到前段页面 把两表的部门名称拿进来--%>
			<td>
				<a href="/product/input?id=${product.id}">编辑</a>
				<a href="/product/delete?id=${product.id}">删除</a>
			</td>
		</tr>
	</c:forEach>

	<tr>
		<td colspan="8" align="center">
			<a href="javascript:;" onclick="goPage(1)">首页</a>
			<a href="javascript:;" onclick="goPage(${pageResult.prevPage})">上一页</a>
			<a href="javascript:;" onclick="goPage(${pageResult.nextPage})">下一页</a>
			<a href="javascript:;" onclick="goPage(${pageResult.totalPage})">末页</a>
			每页显示:<select name="pageSize" onchange="goPage(1)">
				<option value ="2" ${pageResult.pageSize == 2 ? 'selected' : ''}>2</option>
				<option value ="3" ${pageResult.pageSize == 3 ? 'selected' : ''}>3</option>
				<option value ="4" ${pageResult.pageSize == 4 ? 'selected' : ''}>4</option>
			</select>
			 ${pageResult.currentPage }/${pageResult.totalPage } 页
			跳转:<input type="text" name="currentPage" style="width: 30px" value="${pageResult.currentPage}">
			<input type="submit" value="GO"/>
		</td>
	</tr>
</table>

</form>



</body>
</html>